/*
* author : douyu
* date : 2024/1/9 16:04
* description : custom_dialog
*/


import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

/// 退出app 按钮
void showQuitAppDialog(BuildContext context) {
  showDialog(
    barrierDismissible: false,
    context: context,
    builder: (BuildContext context) {
      return Dialog(
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), // 这里设置对话框外观的圆角
        child: Container(
          padding: const EdgeInsets.all(20),
          constraints: const BoxConstraints(maxHeight: 300,maxWidth: 350), // 设置对话框高度最大值
          child: Column(
            mainAxisSize: MainAxisSize.min, // 设置子控件占用的空间尽可能小
            children: <Widget>[
              const Text("标题",  style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20)),
              const SizedBox(height: 16),
              const Text("确定要离开 IPTV 直播吗?"),
              const SizedBox(height: 24),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  TextButton(
                      style: TextButton.styleFrom(
                          foregroundColor: Colors.white,
                          backgroundColor: Colors.blue,
                          padding: const EdgeInsets.symmetric(horizontal: 10),
                          shape: const RoundedRectangleBorder(
                              borderRadius: BorderRadius.all(Radius.circular(5))
                          )
                      ),
                      onPressed: (){
                        Navigator.of(context).pop();
                      },
                      child: const Text("再想想😁😁", style: TextStyle(color: Colors.black,fontSize: 16),)
                  ),
                  const SizedBox(width: 20,),
                  TextButton(
                      style: TextButton.styleFrom(
                          foregroundColor: Colors.white,
                          backgroundColor: Colors.blue,
                          padding: const EdgeInsets.symmetric(horizontal: 10),
                          shape: const RoundedRectangleBorder(
                              borderRadius: BorderRadius.all(Radius.circular(5))
                          )
                      ),
                      onPressed: (){
                        exit(0);//强制退出App
                      },
                      child: const Text("忍痛离开😂😂", style: TextStyle(color: Colors.black,fontSize: 16),)
                  ),
                ],
              )
            ],
          ),
        ),
      );
    },
  );
}